﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using DTO;
using BUS;

public partial class KetQuaTimKiemDienThoaiNangCao : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string hangsanxuat = Request.QueryString["hangsanxuat"];
            string kieudang = Request.QueryString["kieudang"];
            string kichthuocmanhinh = Request.QueryString["kichthuocmanhinh"];
            bool bonhotrong = bool.Parse(Request.QueryString["bonhotrong"]);
            bool bonhongoai = bool.Parse(Request.QueryString["bonhongoai"]);
            bool _3g = bool.Parse(Request.QueryString["3g"]);
            bool wifi = bool.Parse(Request.QueryString["wifi"]);
            if (TimKiemNangCao(hangsanxuat, kieudang, kichthuocmanhinh,
                bonhotrong, bonhongoai, _3g, wifi) == false)
            {
                lbThongBaoKetQuaTimKiem.Text = "Không có sản phẩm tìm kiếm tương ứng";
                lbThongBaoKetQuaTimKiem.Visible=true;
            }
        }
    }

    private bool TimKiemNangCao(string hangsanxuat, string kieudang, string kichthuocmanhinh,
        bool bonhotrong, bool bonhongoai, bool _3g, bool wifi)
    {
        List<SanPhamDTO> result = ChiTietDienThoaiBUS.TimKiemDienThoaiNangCao(hangsanxuat, kieudang, kichthuocmanhinh,
            bonhotrong, bonhongoai, _3g, wifi);
        if (result.Count > 0)
        {
            CollectionPager3.PageSize = 9;
            CollectionPager3.DataSource = result;
            CollectionPager3.BindToControl = dtlKetQuaTimKiem;
            dtlKetQuaTimKiem.DataSource = CollectionPager3.DataSourcePaged;
            return true;
        }
        return false;
    }
}
